;-> MIDIConstants by Stefano Maria Regattin
;d> 27 Febbraio 2002 da MIDIDefs.h
;m> 1,15,16 marzo 2002
;m> 10,19 aprile 2002
;m> 4,5 novembre 2002
;m> 4,6 dicembre 2002
;m> 15 novembre 2003
;--------------------

;***************
;* C. A. M. D. *
;******************************************************
;* CMU AMIGA Midi Driver - Carnegie Mellon University *
;******************************************************
;* 1988 - Commodore AMIGA *
;***********************************************
;* Design & Development  - Roger B. Dannenberg *
;***********************************************
;* - Jean-Christophe Dhellemmes *
;********************************
;* - Bill Barton *
;*********************************************
;* Copyright 1989 Carnegie Mellon University *
;*********************************************

;****************
;*              *
;* Status Bytes *
;*              *
;****************

;* channel voice messages (1sssnnnn) (OR with channel number) *
#_NoteOff=-128;             $80
#_NoteOn=-112;              $90
#_PolyphonicKeyPressure=-96;$A0
#_ControlChange=-80;        $B0
#_Mode=-80;                 $B0
#_ProgramChange=-64;        $C0
#_ChannelKeyPressure=-48;   $D0
#_PitchBend=-32;            $E0

#_StatusBits=-16;           $F0
#_ChannelBits=15;           $0F, useful values from 0 to 15, that are MIDI
;                                channels from 1 to 16

;* system common messages (11110sss) *
#_System=-16 ;* min system status byte *
#_SystemExclusive=-16;      $F0
#_QtrFrame=-15;             $F1
#_SongPos=-14;              $F2
#_SongSelect=-13;           $F3
#_TuneReq=-10;              $F6
#_EOX=-9;                   $F7

;* system real time messages (11111sss) *
#_RealTime=$F8 ;* Min real time status byte *
#_Clock=-8;                 $F8
#_Start=-6;                 $F9
#_Continue=-5;              $FA
#_Stop=-4;                  $FB
#_ActiveSense=-2;           $FE
#_Reset=-1;                 $FF


;************************
;*                      *
;* Standard Controllers *
;*                      *
;************************

;* Continuous 14 bit - MSB: 0-1F, LSB: 20-3F *
#_Bank=$00
#_ModulationWheel=$01
#_Breath=$02
#_Foot=$04
#_PortaTime=$05
#_DataEntry=$06
#_Volume=$07
#_Balance=$08
#_Pan=$0A
#_Expression=$0B
#_GeneralOne=$10
#_GeneralTwo=$11
#_GeneralThree=$12
#_GeneralFour=$13

;* Continuous 7 bit (switches: 0-3F=Off, 40-7F=On) *
#_Sustain=$40
#_Portamento=$41
#_Sostenuto=$42
#_SoftPedal=$43
#_HoldTwo=$45
#_GeneralFive=$50
#_GeneralSix=$51
#_GeneralSeven=$52
#_GeneralEight=$53
#_ExtDepth=$5B
#_TremoloDepth=$5C
#_ChorusDepth=$5D
#_CelesteDepth=$5E
#_PhaserDepth=$5F

;* Parameters *
#_DataInc=$60
#_DataDec=$61
#_NRPNL=$62
#_NRPNH=$63
#_RPNL=$64
#_RPNH=$65

#_ControllerMaxValue=$78

;*****************
;*               *
;* Channel Modes *
;*               *
;*****************

#_MinModeValue=$79

#_ResetCtrl=$79
#_Local=$7A
#_AllNotesOff=$7B
#_OmniOff=$7C
#_OmniOn=$7D
#_Mono=$7E
#_Poly=$7F


;********************************
;*                              *
;* Registered Parameter Numbers *
;*                              *
;***************************************************************************
;* these are 16 bit values that need To be separated into two bytes for use
;* with the _RPNH & _RPNL messages using 8 bit math (hi=MRP>>8,lo=MRP_&$FF)
;* as opposed To 7 bit math. this is done so that the defines match the
;* numbers from the MMA. see MIDI 1.0 Detailed Spec v4.0 pp 12, 23 For more
;* info.
;********

#_PBSens=$0000
#_FineTune=$0001
#_CourseTune=$0002


;******************************
;*                            *
;* MTC Quarter Frame messages *
;*                            *
;*****************************************
;* Qtr Frame message is F1 0nnndddd where
;*
;* nnn is a message Type defined below
;* dddd is 4 bit Data nibble For those message types
;*
;* each pair of nibbles is combined by the receiver into a single byte. there
;* are masks and type values defined for some of these Data bytes below.
;************************************************************************

;* Message Types *
#_FrameL=$00
#_FrameH=$10
#_SecL=$20
#_SecH=$30
#_MinL=$40
#_MinH=$50
#_HourL=$60
#_HourH=$70 ;* also contains time code type *

;* Message Masks */
#_TypeMask=%01110000 ;* mask for type bits in message *
#_DataMask=%00001111 ;* mask for data bits in message *

;* Hour Byte */
#_HourTypeMask=$60 ;* mask for time code type *
#_HourMask=$1f ;* hours mask (range 0-23) *

;* Time code Type values For hour byte */
#_24FramesPerSecond=$00
#_25FramesPerSecond=$20
#_30FramesPerSecondDrop=$40
#_30FramesPerSecondNoDrop=$60

;*********************
;*                   *
;* Sys/Ex ID numbers *
;*                   *
;*****************************************************************************
;* now includes 3 byte extension For the American Group. this new format uses
;* a $00 as the sys/ex id followed by two additional bytes that actually
;* identify the manufacturer. these new extended id constants are 32 bit
;* values with 24 significant bits.
;***********************************

;* north american group (1 byte) *
#_MID_Sequential=$01
#_MID_IDP=$02
#_MID_OctavePlateau=$03
#_MID_Moog=$04
#_MID_Passport=$05
#_MID_Lexicon=$06
#_MID_Kurzweil=$07
#_MID_Fender=$08
#_MID_Gulbransen=$09
#_MID_AKG=$0A
#_MID_Voyce=$0B
#_MID_Waveframe=$0C
#_MID_ADA=$0D
#_MID_Garfield=$0E
#_MID_Ensoniq=$0F
#_MID_Oberheim=$10
#_MID_Apple=$11
#_MID_GreyMatte=$12
#_MID_PalmTree=$14
#_MID_JLCooper=$15
#_MID_Lowrey=$16
#_MID_AdamsSmith=$17
#_MID_Emu=$18
#_MID_Harmony=$19
#_MID_ART=$1A
#_MID_Baldwin=$1B
#_MID_Eventide=$1C
#_MID_Inventronics=$1D
#_MID_Clarity=$1F

;* north american group (3 bytes) *
#_MID_XAmerica=$00 ;* north american 3 bytes prefix *

#_MIDX_DigitalMusic=$000007
#_MIDX_Iota=$000008
#_MIDX_Artisyn=$00000A
#_MIDX_IVL=$00000B
#_MIDX_SouthernMusic=$00000C
#_MIDX_LakeButler=$00000D
#_MIDX_DOD=$000010
#_MIDX_PerfectFret=$000014
#_MIDX_KAT=$000015
#_MIDX_Opcode=$000016
#_MIDX_Rane=$000017
#_MIDX_SpatialSound=$000018
#_MIDX_KMX=$000019
#_MIDX_Brenell=$00001A
#_MIDX_Peavey=$00001B
#_MIDX_360=$00001C
#_MIDX_Axxes=$000020
#_MIDX_CAE=$000026
#_MIDX_Cannon=$00002B
#_MIDX_BlueSkyLogic=$00002E
#_MIDX_Voce=$000031

;* european group */
#_MID_SIEL=$21
#_MID_Synthaxe=$22
#_MID_Hohner=$24
#_MID_Twister=$25
#_MID_Solton=$26
#_MID_Jellinghaus=$27
#_MID_Southworth=$28
#_MID_PPG=$29
#_MID_JEN=$2A
#_MID_SSL=$2B
#_MID_AudioVeritrieb=$2C
#_MID_Elka=$2F
#_MID_Dynacord=$30
#_MID_Clavia=$33
#_MID_Soundcraft=$39

;* japanese group */
#_MID_Kawai=$40
#_MID_Roland=$41
#_MID_Korg=$42
#_MID_Yamaha=$43
#_MID_Casio=$44
#_MID_Kamiya=$46
#_MID_Akai=$47
#_MID_JapanVictor=$48
#_MID_Mesosha=$49

;* universal ID Numbers *
#_MID_UNC=$7D
#_MID_UNRT=$7E
#_MID_URT=$7F

;*****************
;*               *
;* Miscellaneous *
;*               *
;*****************

#_MiddleC=60 ;* Middle C note value *
#_DefaultVelocity=64 ;* default note ON or OFF velocity *
#_PitchBendCenter=$2000 ;* pitch bend center position as a 14 bit word *
#_MClksPerQtr=24  ;* MIDI clocks per quarter note *
#_MClksPerSP=6 ;* MIDI clocks per song position index *
#_PanAndSimilarCenter=64 ;* center value for controllers like pan and balance *

;***************************************
;*                                     *
;* Standard MIDI File Format Constants *
;*                                     *
;***************************************

;* Header Chunk *

HeaderMarker$="MThd" ;four chars, that are four bytes
#_MarkerLength=6      ;word, that are two bytes

#_FormatZero=0        ;word
#_FormatOne=1         ;word
#_FormatTwo=2         ;word
;You must select only one of these!

;These constants represent the standard MIDI file header structure; must be
; followed by the number of tracks as a word and after this by the ticks per
; quarter notes as a word; if this last is a negative number it is the SMPTE
; time encoding stated as follows:
;bit 8-14 -> video frames per second; useful values 25, 28, 29 or 30.
;bit 0-7  -> ticks per video frames; useful values 4, 8, 10 or 80.

;* Track Chunk *

TrackMarker$="MTrk" ;four chars, that are four bytes.
;The track header must be followed by the length of the track as a four bytes
; number; after this must come the delta time of the event to come and then
; the event; the delta time is structured as one or more bytes as required,
; where each 0-6 bits of the byte represent the length by ticks and must be
; added to the previous one and if there is another byte to come the bit 7
; will retain 1, otherwise it will retain 0.

;After the delta time byte or bytes, must come the event, that must be a MIDI
; event, a SYStem EXclusive event or another kind of event that is useful to
; the sequencer.
;The SYSEX event has the following syntax:
; F0     ;a byte
; Length ;as delta time

;There is another way to represent SYSEX events, that is as follows:
; F7     ;a byte
; Length ;as delta time
; Event  ;an unknown byte

#_MetaEvent=-1 ;$FF ,a byte
;The last kind of events that aren't MIDI or SYSEX events are as follows:
; FF     ;a byte for the meta event identifier
; Type   ;a byte
; Length ;as delta time
; Datum  ;a byte
;If there isn't the datum, the length is of one byte and is zero, where also
; the bit 7 is zero, stating the end of the delta time.
;The type of these events are the following:

#_SequenceNumber=0
;A byte that must be followed by a byte retaining a value of 2 that states the
; Lenght of the incoming word that retains the sequence number (for the
; Standard MIDI File Format Two, or the track number for the others Zero and
; One Standard MIDI File Format); for the Standard MIDI File Format Zero the
; track is unique.
;At end comes the Sequence (or track) numbers, that is represented by a word.

#_Text=1
;This allows to insert a text into the MIDI file.

#_Copyright=2
;This allows to insert the copyright into the MIDI file.

#_SequenceName=3
;This allows to insert the name of the sequence, for the Format Two, for track
; for the Format Zero and One.

#_InstrumentName=4
;This allows to insert the name of the instruments.

#_Lyric=5
;This allows to insert the words of the song.

#_NameMarker=6
;This allows to insert a name to a point of the song.

#_CuePoint=7
;This allows to insert a reminder to a point of the song.

#_MIDIChannelPrefix=$20
;This states that all the following events have the same MIDI channel until
; otherwise specified.

#_EndOfTrackChunk=$2F
;This states the end of the track chunk.

#_TempoChange=$51
;This allows to insert a microseconds per quarter note tempo variation.

#_SMPTEStartOffset=$54
;This states the start time of the track chunk represented in the SMPTE
; format.

#_TimeSignatureChange=$58
;This allows to change the time signature, where the first byte is the
; numerator and the following byte is the denominator as power of two number;
; follows the MIDI ticks for a beat and the last byte retains the number of
; thirtysecond notes for a quarter, there are usually 24 ticks.

#_KeySignatureChange=$59
;This allows to change the kind of scale by its Diesis (#) or Bemoll (b),
; where the first byte retains the number of the alterations (# or b), as
; follows:
;equal to Zero=no alteration (Do/C scale)
;greater than Zero (value from 1 to 7)=number of Diesis (#)
;less than Zero (value from -1 to -7)=number of Bemolls (b)
; The following byte states if the scale is major (value 0) or minor (value
; 1).

#_OutOfStandard=$7F
;This allows to insert data related to a specific kind of musical instruments.
